cmake_minimum_required(VERSION 3.27)

# 递归查找当前目录下的所有源文件
file(
    GLOB_RECURSE
    ${PROJECT_NAME}_SourceFile
    *.cpp *.c
)
file(
    GLOB_RECURSE
    ${PROJECT_NAME}_HeaderFile
    *.h *.xml
)

# 不能传递到父类
# list(
#     APPEND
#     ${PROJECT_NAME}_SourceFile
#     ${SRC}
# )

target_sources(${PROJECT_NAME} PRIVATE
    ${${PROJECT_NAME}_SourceFile}
    ${${PROJECT_NAME}_HeaderFile}
)

add_custom_target(buildRes ALL
    COMMAND ${CMAKE_COMMAND} -E copy_directory
    ${CMAKE_CURRENT_SOURCE_DIR}/app_resource
    $<TARGET_FILE_DIR:${PROJECT_NAME}>/app_resource
    COMMENT "Copying files from ${CMAKE_CURRENT_SOURCE_DIR}/app_resource to $<TARGET_FILE_DIR:${PROJECT_NAME}>/app_resource"
)
# 设置项目依赖关系，编译${PROJECT_NAME}前先编译buildRes
add_dependencies(${PROJECT_NAME} buildRes)